﻿@{
    ViewBag.Title = "UpdateUnitInfo";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    
    <link href="//unpkg.com/layui@2.9.17/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">单位编码</label>
            <div class="layui-input-block">
                <input type="text" name="unitCode" id="unitCode" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单位名称</label>
            <div class="layui-input-block">
                <input type="text" name="unitName" id="unitName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否主单位</label>
            <div class="layui-input-block">
                <input type="radio" name="unitFlag" value="1" title="是" checked>
                <input type="radio" name="unitFlag" value="0" title="否">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="isEnable" value="1" title="是" checked>
                <input type="radio" name="isEnable" value="0" title="否">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="remark" id="remark"></textarea>
            </div>
        </div>
        <input type="hidden" id="id" name="id" >
    </form>

    <script src="~/libs/jquery/jquery.js"></script>
    <script src="//unpkg.com/layui@2.9.16/dist/layui.js"></script>

    <script type="text/javascript">
        layui.use('form', function () {
            var form = layui.form;
            form.render();
            var meaid = window.location.search.substring(4);
            console.log(meaid);
            $.ajax({
                url: '/Jiang/GetUnitInfo?id='+meaid,
                type: 'get',
                DataTransfer: $('form').serialize(),
                success: function (res) {
                    $('#unitCode').val(res.unitCode);
                    $('#unitName').val(res.unitName);
                    $("input[name='unitFlag'][value='" + res.unitFlag + "']").prop("checked", true);
                    $("input[name='isEnable'][value='" + res.isEnable + "']").prop("checked", true);
                    $('#remark').val(res.remark);
                    $('#id').val(res.id);
                }
            });
        })
    </script>
</body>
</html>